//   创建个人信息对象
// var person = {
//     personName:null,
//     personStatus:null,//身份
//     personEducation:null,//学历
//     jobHunting:null,//求职状态
//     personTelephone:null,//电话
//     personWeChat:null,//微信
//     personEmail:null,//邮箱
//     personGender:null,//性别
//     personImg:null,//头像
//     personBirthday:null,//生日
//     personEdge:null,//个人优势
//     // 期望职位
//     ExpectedJob:null,//期望职位
//     ExpectedIndustry:null,//期望行业
//     ExpectedSarlay:null,//薪资要求
//     ExpectedCity:null,//工作城市
//     JobType:null,//求职类型
//     // 实习经历
//     internshipCompany:null,//公司
//     jobTime1:null,//在职时间
//     jobTime2:null,//在职时间
//     Industry:null,//行业
//     Department:null,//所属部门
//     jobName:null,//职位名称
//     jobContent:null,//工作内容
//     jobSkills:null,//拥有技能
//     // 项目经历
//     projectName:null,//项目名称
//     projectTime:null,//项目时间
//     projectRole:null,//项目角色
//     projectcontent:null,//内容
//     projectAchievement:null,//项目业绩
//     projectLink:null,//项目链接
//     // 教育经历
//     shoolName:null,
//     shoolType:null,
//     education:null,//学历
//     major:null,//专业
//     studyTime:null,
//     shoolExperience:null
// }

//===================================================
//登陆信息
var myResumeId;
var idInternship;


loadCvData();
function loadCvData(){
    console.log("=====登陆信息显示======");
    var token = localStorage.getItem("token");//获得在登录界面生成的 token
    console.log("CV获得的token-----:" + token);
    $.ajax({
        async:false,
        type: "get",
        url: "../../cvLoadData",//与myresumeController的 testIndex方法实现前后端数据交互
        headers:{"token": token},
        success:function (result){
            var data = result.data;
            if(data===null){
                //在没有查询到该用户的简历id时，创建一个用户简历id
                $.ajax({
                    async:false,
                    type: "get",
                    url: "../../insertMyResume",
                    headers:{"token": token},
                    success:function (result){
                        myResumeId = result.data.myresumeId;
                        var loginUser = result.data;
                        var data = result.data;
                        if (loginUser != null){
                            $(".login_info1").css("display","block");
                            $(".login_info").css("display","none"); //======myresume表信息修改==============
                            // 个人信息
                            var myresumeTel = data.myresumeTel;//微信=电话
                            $(".utel").text(myresumeTel);
                            $(".uWeChat").text(myresumeTel);
                            $(".tab_tel").val(myresumeTel);
                            $(".tab_weChat").val(myresumeTel);
                            var personEmail = data.myresumeEmail;
                            $(".uemail").text(personEmail);
                            $(".tab_email").val(personEmail);
                            var test1 = data.test1;
                            $(".capacity").val(test1);
                            $("#preCapacity").text(test1);


                            //个人优势
                            var personEdge = data.personalAdvantages;
                            $(".personAdv").val(personEdge);
                            $(".prePersonAdv").text(personEdge);
                            // 期望
                            var ExpectedJob = data.expectedPosition;
                            preExpectedJob=ExpectedJob;
                            console.log("=====================预览页面=================ExpectedJob"+ExpectedJob)
                            $(".eJob").text(ExpectedJob);
                            $("#prePersonExJob").text(ExpectedJob);
                            $(".ejob").val(ExpectedJob);

                            var ExpectedIndustry = data.expectedIndustry
                            $(".eIndustry").text(ExpectedIndustry);
                            $(".eindustry").val(ExpectedIndustry);
                            if ((data.expectationSalaryMin) != null || (data.expectationSalaryMax != null)){
                                // $(".job_salary1").css("display","none");
                                // $(".job_salary2").css("display","block");
                                var expectationSalaryMin = data.expectationSalaryMin;
                                var expectationSalaryMax = data.expectationSalaryMax;
                                // $(".minsalary").text(expectationSalaryMin);
                                // $(".maxsalary").text(expectationSalaryMax);
                                var sala = expectationSalaryMin+"-"+expectationSalaryMax;
                                $(".eSarlay").text(sala);
                                $("#tab_sarlay").val(sala);
                                console.log("=====================预览页面=================preSarlay"+sala)
                                $("#preSarlay").text(sala);
                            }
                            var ExpectedCity = data.workArea;
                            console.log("------区域------"+ExpectedCity)
                            $(".eCity").text(ExpectedCity);
                            $(".tab_city").val(ExpectedCity);
                            // id
                            var personId = data.personId;
                            var myresumeId = data.myresumeId;


                            // 获取实习经历id
                            var internshipId = data.internshipId;
                            idInternship = internshipId
                            console.log("internshipIdbbbbbbbbbbb"+internshipId)
                            //    ===== 个人中心表 ==========1
                            $.ajax({
                                type: "get",
                                async:false,
                                url: "../../getPerNameByPerId?personId="+personId,
                                success: function (result) {
                                    console.log(result);
                                    var data = result.data;
                                    //    页面换值
                                    var age = data.personAge;
                                    $(".age").text(age);
                                    var personBirthday = data.personBirthday;
                                    $("#test1").val(personBirthday);
                                    var personName = data.personName;

                                    $("#Tip1").text(personName);
                                    $(".un_text").text(personName);
                                    $(".tab_username").val(personName);
                                    prePersonName=personName;
                                    console.log("=====================预览页面================="+personName)
                                    $("#preName").text(personName);
                                    var personGender=data.personGender;
                                    $("#tab_Gender").val(personGender);
                                    $(".rigGender").text(personGender);
                                    var status=data.personJobStatus;//我的身份
                                    $(".ustatus").text(status);
                                    $("#tab_status").val(status);
                                    var jobHunting=data.text1 //求职状态
                                    $(".jobHunting").text(jobHunting);
                                    $("#tab_jobHunting").val(jobHunting);
                                    var both = data.personBirthday;
                                    $("#bothday").val(both);

                                },
                            })
                            //    ===== 实习经历表 ==========
                            //    将myresumeId传到controller
                            $.ajax({
                                type: "get",
                                url: "../../getInternshipByreId?internshipId="+internshipId,
                                success: function (result) {
                                    console.log(result);
                                    var data = result.data;
                                    //    页面换值
                                    // 在职时间
                                    if ((data.jobCreateTime) != null || (data.jobEndTime != null)){
                                        $(".ujobTime1").css("display","none");
                                        $(".ujobTime2").css("display","block");
                                        var jobCreateTime = data.jobCreateTime;
                                        var jobEndTime = data.jobEndTime;
                                        console.log("实习经历EndTime"+jobEndTime)
                                        $(".ujobTimeStart").text(jobCreateTime);
                                        $("#test-startDate-61").val(jobCreateTime);
                                        $(".ujobTimeEnd").text(jobEndTime);
                                        $("#test-endDate-62").val(jobEndTime);
                                        var preProjectTime = jobCreateTime+"至"+jobEndTime;
                                    }
                                    // 所属部门
                                    var Industry = data.departmentName;
                                    $(".uIndustry").text(Industry);
                                    $(".tab_Industry").val(Industry);
                                    var jobName = data.jobName;
                                    $(".uJobName").text(jobName);
                                    $("#tab_jobName").val(jobName);
                                    var jobContent = data.jobContent;
                                    $(".ujobContent").text(jobContent);
                                    $(".tab_jobContent").val(jobContent);
                                    var jobSkills = data.jobSkills;
                                    console.log("拥有技能---------"+jobSkills)
                                    $(".ujobSkills").text(jobSkills);
                                    $(".tab_jobSkills").val(jobSkills);

                                    // ====== 公司表 ======
                                    //根据公司id查公司信息
                                    companyId = data.companyId;
                                    console.log("companyIdbbbbbbbbbbbbbbb"+companyId)
                                    $.ajax({
                                        type: "get",
                                        url: "../../getCompanyById?companyId=" + companyId,
                                        success: function (result) {
                                            console.log(result);
                                            var data = result.data;
                                            //    页面换值！！！！
                                            // 公司名，查公司详情表
                                            var internshipCompany = data.companyName;
                                            $(".ucompany").text(internshipCompany);
                                            $(".tab_company").val(internshipCompany);
                                            // 所属行业，查公司详情表
                                            var Department = data.companyIndustry;
                                            $(".uDepartment").text(Department);
                                            $("#tab_Department").val(Department);
                                        }
                                    })
                                },

                            })
                            //    ===== 项目经历表 ==========
                            //    将myresumeId传到controller
                            $.ajax({
                                type: "get",
                                url: "../../experCienceProject/getProjectByreId?resumeId="+myresumeId,
                                success: function (result) {
                                    console.log(result);
                                    var data = result.data;
                                    //    页面换值
                                    var projectName = data.projectName;
                                    $(".uprojectName").text(projectName);
                                    console.log("=====================预览页面=================preProjectName"+projectName)
                                    preProjectName=projectName;
                                    console.log("=====================预览页面AAA=================preProjectName"+preProjectName)
                                    $("#preProjectName").text(projectName);
                                    $(".tab_projectName").val(projectName);
                                    if ((data.projectCreateTime) != null || (data.projectEndTime != null)){
                                        $(".uprojectTime1").css("display","none");
                                        $(".uprojectTime2").css("display","block");
                                        var projectCreateTime = data.projectCreateTime;
                                        var projectEndTime = data.projectEndTime;
                                        $(".uprojectTimeStart").text(projectCreateTime);
                                        $("#test-startDate-71").val(projectCreateTime);
                                        $(".uprojectTimeEnd").text(projectEndTime);
                                        $("#test-endDate-72").val(projectEndTime);
                                        var preProjectTime = projectCreateTime+"至"+projectEndTime;
                                        $("#preProjectTime").text(preProjectTime);
                                    }
                                    //项目角色
                                    var projectRole = data.projectOperation;
                                    $(".uprojectRole").text(projectRole);
                                    $(".tab_projectRole").val(projectRole);
                                    var projectcontent = data.projectDescription;
                                    $(".uprojectcontent").text(projectcontent);
                                    $(".tab_projectcontent").val(projectcontent);
                                    $(".preProjectRole").text(projectcontent);
                                    console.log("=====================预览页面=================projectcontent"+projectcontent)
                                    preProjectcontent=projectcontent;
                                    console.log("=====================预览页面AAA=================projectcontent"+preProjectcontent)

                                    var projectAchievement = data.projectPerformance;
                                    $(".uprojectAchievement").text(projectAchievement);
                                    $(".tab_projectAchievement").val(projectAchievement);
                                    //    实习业绩
                                    $("#preAchievement").text(projectAchievement);
                                    var projectLink = data.projectUrl;
                                    $(".uprojectLink").text(projectLink);
                                    $(".tab_projectLink").val(projectLink);
                                },
                            })
                            console.log(myResumeId+"---"+idInternship+"===235")
                            //    ===== 教育经历表 ==========
                            //    将myresumeId传到controller
                            $.ajax({
                                type: "get",
                                url: "../../edu/getResumeId?resumeId="+myresumeId,//与myresumeController的 testIndex方法实现前后端数据交互
                                success: function (result) {
                                    console.log(result);
                                    var data = result.data;
                                    if(data === null){
                                        console.log("没有教育经历表，所以现在要创建一个教育经历记录")
                                    }else{
                                        //    页面换值
                                        var shoolName = data.educationalName;
                                        $(".sshoolName").text(shoolName);
                                        $("#preShoolName").text(shoolName);
                                        $(".tab_shoolName").val(shoolName);
                                        var studyTime = data.educationalSchoolPeriod;
                                        $(".startDate").val(studyTime);
                                        $(".sstudyTime").text(studyTime);
                                        var major = data.educationalMajor;
                                        console.log(major+"YYYYYYYYYYYYYYYYYY296")
                                        $(".smajor").text(major);
                                        $(".tab_major").val(major);
                                        var education = data.educationalEducation;
                                        $(".ueducation").text(education);
                                        $(".seducation").text(education);
                                        $(".tab_education").val(education);
                                        var shoolExperience = data.educationalAssociationActivity;
                                        $(".sshoolExperience").text(shoolExperience);
                                        $(".tab_shoolExperience").val(shoolExperience);
                                    }

                                }
                            })

                            console.log(myResumeId+"---"+idInternship+"===266");
                        }//if token != null
                    }
                })
            }else{
                myResumeId = result.data.myresumeId;
                console.log("myResumeIdbbbbbbbbbbbbbbb"+myResumeId)
                //======根据获得的token修改用户名称========
                var loginUser = data;
                //如果token不为空，则加载CV页面数据
                if (loginUser != null){
                    $(".login_info1").css("display","block");
                    $(".login_info").css("display","none"); //======myresume表信息修改==============
                    // 个人信息
                    var myresumeTel = data.myresumeTel;//微信=电话
                    $(".utel").text(myresumeTel);
                    $(".uWeChat").text(myresumeTel);
                    $(".tab_tel").val(myresumeTel);
                    $(".tab_weChat").val(myresumeTel);
                    var personEmail = data.myresumeEmail;
                    $(".uemail").text(personEmail);
                    $(".tab_email").val(personEmail);
                    var test1 = data.test1;
                    console.log(personEmail+"TTTTTTTTTTTTTTTTTTTTTTTTTT")
                    $(".capacity").val(test1);
                    $("#preCapacity").text(test1);


                    //个人优势
                    var personEdge = data.personalAdvantages;
                    $(".personAdv").val(personEdge);
                    $(".prePersonAdv").text(personEdge);
                    // 期望
                    var ExpectedJob = data.expectedPosition;
                    preExpectedJob=ExpectedJob;
                    console.log("=====================预览页面=================ExpectedJob"+ExpectedJob)
                    $(".eJob").text(ExpectedJob);
                    $("#prePersonExJob").text(ExpectedJob);
                    $(".ejob").val(ExpectedJob);

                    var ExpectedIndustry = data.expectedIndustry
                    $(".eIndustry").text(ExpectedIndustry);
                    $(".eindustry").val(ExpectedIndustry);
                    if ((data.expectationSalaryMin) != null || (data.expectationSalaryMax != null)){
                        // $(".job_salary1").css("display","none");
                        // $(".job_salary2").css("display","block");
                        var expectationSalaryMin = data.expectationSalaryMin;
                        var expectationSalaryMax = data.expectationSalaryMax;
                        // $(".minsalary").text(expectationSalaryMin);
                        // $(".maxsalary").text(expectationSalaryMax);
                        var sala = expectationSalaryMin+"-"+expectationSalaryMax;
                        $(".eSarlay").text(sala);
                        $("#tab_sarlay").val(sala);
                        console.log("=====================预览页面=================preSarlay"+sala)
                        $("#preSarlay").text(sala);
                    }
                    var ExpectedCity = data.workArea;
                    console.log("------区域------"+ExpectedCity)
                    $(".eCity").text(ExpectedCity);
                    $(".tab_city").val(ExpectedCity);
                    // id
                    var personId = data.personId;
                    var myresumeId = data.myresumeId;


                    // 获取实习经历id
                    var internshipId = data.internshipId;
                    idInternship = internshipId
                    console.log("internshipIdbbbbbbbbbbb"+internshipId)
                    //    ===== 个人中心表 ==========1
                    $.ajax({
                        type: "get",
                        async:false,
                        url: "../../getPerNameByPerId?personId="+personId,
                        success: function (result) {
                            console.log(result);
                            var data = result.data;
                            //    页面换值
                            var age = data.personAge;
                            $(".age").text(age);
                            var personBirthday = data.personBirthday;
                            $("#test1").val(personBirthday);
                            var personName = data.personName;

                            $("#Tip1").text(personName);
                            $(".un_text").text(personName);
                            $(".tab_username").val(personName);
                            prePersonName=personName;
                            console.log("=====================预览页面================="+personName)
                            $("#preName").text(personName);
                            var personGender=data.personGender;
                            $("#tab_Gender").val(personGender);
                            $(".rigGender").text(personGender);
                            var status=data.personJobStatus;//我的身份
                            $(".ustatus").text(status);
                            $("#tab_status").val(status);
                            var jobHunting=data.text1 //求职状态
                            $(".jobHunting").text(jobHunting);
                            $("#tab_jobHunting").val(jobHunting);
                            var both = data.personBirthday;
                            $("#bothday").val(both);

                        },
                    })
                    //    ===== 实习经历表 ==========
                    //    将myresumeId传到controller
                    $.ajax({
                        type: "get",
                        url: "../../getInternshipByreId?internshipId="+internshipId,
                        success: function (result) {
                            console.log(result);
                            var data = result.data;
                            //    页面换值
                            // 在职时间
                            if ((data.jobCreateTime) != null || (data.jobEndTime != null)){
                                $(".ujobTime1").css("display","none");
                                $(".ujobTime2").css("display","block");
                                var jobCreateTime = data.jobCreateTime;
                                var jobEndTime = data.jobEndTime;
                                console.log("实习经历EndTime"+jobEndTime)
                                $(".ujobTimeStart").text(jobCreateTime);
                                $("#test-startDate-61").val(jobCreateTime);
                                $(".ujobTimeEnd").text(jobEndTime);
                                $("#test-endDate-62").val(jobEndTime);
                                var preProjectTime = jobCreateTime+"至"+jobEndTime;
                            }
                            // 所属部门
                            var Industry = data.departmentName;
                            $(".uIndustry").text(Industry);
                            $(".tab_Industry").val(Industry);
                            var jobName = data.jobName;
                            $(".uJobName").text(jobName);
                            $("#tab_jobName").val(jobName);
                            var jobContent = data.jobContent;
                            $(".ujobContent").text(jobContent);
                            $(".tab_jobContent").val(jobContent);
                            var jobSkills = data.jobSkills;
                            console.log("拥有技能---------"+jobSkills)
                            $(".ujobSkills").text(jobSkills);
                            $(".tab_jobSkills").val(jobSkills);

                            // ====== 公司表 ======
                            //根据公司id查公司信息
                            companyId = data.companyId;
                            console.log("companyIdbbbbbbbbbbbbbbb"+companyId)
                            $.ajax({
                                type: "get",
                                url: "../../getCompanyById?companyId=" + companyId,
                                success: function (result) {
                                    console.log(result);
                                    var data = result.data;
                                    //    页面换值！！！！
                                    // 公司名，查公司详情表
                                    var internshipCompany = data.companyName;
                                    $(".ucompany").text(internshipCompany);
                                    $(".tab_company").val(internshipCompany);
                                    // 所属行业，查公司详情表
                                    var Department = data.companyIndustry;
                                    $(".uDepartment").text(Department);
                                    $("#tab_Department").val(Department);
                                }
                            })
                        },

                    })
                    //    ===== 项目经历表 ==========
                    //    将myresumeId传到controller
                    $.ajax({
                        type: "get",
                        url: "../../experCienceProject/getProjectByreId?resumeId="+myresumeId,
                        success: function (result) {
                            console.log(result);
                            var data = result.data;
                            //    页面换值
                            var projectName = data.projectName;
                            $(".uprojectName").text(projectName);
                            console.log("=====================预览页面=================preProjectName"+projectName)
                            preProjectName=projectName;
                            console.log("=====================预览页面AAA=================preProjectName"+preProjectName)
                            $("#preProjectName").text(projectName);
                            $(".tab_projectName").val(projectName);
                            if ((data.projectCreateTime) != null || (data.projectEndTime != null)){
                                $(".uprojectTime1").css("display","none");
                                $(".uprojectTime2").css("display","block");
                                var projectCreateTime = data.projectCreateTime;
                                var projectEndTime = data.projectEndTime;
                                $(".uprojectTimeStart").text(projectCreateTime);
                                $("#test-startDate-71").val(projectCreateTime);
                                $(".uprojectTimeEnd").text(projectEndTime);
                                $("#test-endDate-72").val(projectEndTime);
                                var preProjectTime = projectCreateTime+"至"+projectEndTime;
                                $("#preProjectTime").text(preProjectTime);
                            }
                            //项目角色
                            var projectRole = data.projectOperation;
                            $(".uprojectRole").text(projectRole);
                            $(".tab_projectRole").val(projectRole);
                            var projectcontent = data.projectDescription;
                            $(".uprojectcontent").text(projectcontent);
                            $(".tab_projectcontent").val(projectcontent);
                            $(".preProjectRole").text(projectcontent);
                            console.log("=====================预览页面=================projectcontent"+projectcontent)
                            preProjectcontent=projectcontent;
                            console.log("=====================预览页面AAA=================projectcontent"+preProjectcontent)

                            var projectAchievement = data.projectPerformance;
                            $(".uprojectAchievement").text(projectAchievement);
                            $(".tab_projectAchievement").val(projectAchievement);
                            //    实习业绩
                            $("#preAchievement").text(projectAchievement);
                            var projectLink = data.projectUrl;
                            $(".uprojectLink").text(projectLink);
                            $(".tab_projectLink").val(projectLink);
                        },
                    })
                    console.log(myResumeId+"---"+idInternship+"===235")
                    //    ===== 教育经历表 ==========
                    //    将myresumeId传到controller
                    $.ajax({
                        type: "get",
                        url: "../../edu/getResumeId?resumeId="+myresumeId,//与myresumeController的 testIndex方法实现前后端数据交互
                        success: function (result) {
                            console.log(result);
                            var data = result.data;
                            console.log(data+"rrrrrrrrrrrrrrrrrrrrrrrrrrrrrr")
                            //    页面换值

                            var shoolName = data.educationalName;
                            $(".sshoolName").text(shoolName);
                            $("#preShoolName").text(shoolName);
                            $(".tab_shoolName").val(shoolName);
                            var studyTime = data.educationalSchoolPeriod;
                            $(".startDate").val(studyTime);
                            $(".sstudyTime").text(studyTime);
                            var major = data.educationalMajor;
                            console.log(major+"YYYYYYYYYYYYYYYYYYYYYYYYYYYYY541")
                            $(".smajor").text(major);
                            $(".tab_major").val(major);
                            var education = data.educationalEducation;
                            $(".ueducation").text(education);
                            $(".seducation").text(education);
                            $(".tab_education").val(education);
                            var shoolExperience = data.educationalAssociationActivity;
                            $(".sshoolExperience").text(shoolExperience);
                            $(".tab_shoolExperience").val(shoolExperience);
                        }
                    })

                    console.log(myResumeId+"---"+idInternship+"===266");
                }//if token != null
            }
        }

    })

}//Data

// 监听按钮修改保存
// ====================== CV 个人信息=================================
// 原生JS隐藏div
document.querySelector(".mesBt").onclick = function(){
    document.querySelector(".userMes").style.display ="none";
    document.querySelector(".cenTab1").style.display ="none";
}

// jQuery显示 编辑框
$(".mesBt").click(function(){
    $(".cenTab1").slideDown();
})

// 完成编辑切换显示框
// 完成按钮
$(".finishBt1").click(function(){
    $(".cenTab1").slideUp();
    $(".userMes").slideDown();
})
// 取消按钮
$(".removeBt1").click(function(){
    $(".cenTab1").slideUp();
    $(".userMes").slideDown();
})
//个人优势
// 原生JS隐藏div
document.querySelector(".userAdvBt").onclick = function(){
    document.querySelector(".advInpt1").style.display ="none";
    document.querySelector(".advInpt2").style.display ="none";
    document.querySelector(".credInpt").style.display ="none";
}

// jQuery显示 编辑框
$(".userAdvBt").click(function(){
    $(".advInpt2").slideDown();
    $(".credInpt").css("display","none");
})

// 完成编辑切换显示框
// 完成按钮
$(".finishBtAdv").click(function(){
    $(".advInpt2").slideUp();
    $(".advInpt1").slideDown();
    $(".credInpt").css("display","block");
    $("#userCredEdi").css("display","none");
})

// ====================== CV 期望职位=================================
// 原生JS隐藏div
document.querySelector(".hopeBt").onclick = function(){
    document.querySelector(".hope").style.display ="none";
    document.querySelector(".cenTab2").style.display ="none";
}

// jQuery显示 编辑框
$(".hopeBt").click(function(){
    $(".cenTab2").slideDown();
})
// 完成编辑切换显示框
$(".finishBt2").click(function(){
    $(".cenTab2").slideUp();
    $(".hope").slideDown();
})
$(".removeBt2").click(function(){
    $(".cenTab2").slideUp();
    $(".hope").slideDown();
})

// ====================== CV 实习经历 3 =================================
// 原生JS隐藏div
document.querySelector(".expBt").onclick = function(){
    document.querySelector(".exp").style.display ="none";
    document.querySelector(".cenTab3").style.display ="none";
}

// jQuery显示 编辑框
$(".expBt").click(function(){
    $(".cenTab3").slideDown();
})

// 完成编辑切换显示框
$(".finishBt3").click(function(){
    $(".cenTab3").slideUp();
    $(".exp").slideDown();
})
$(".removeBt3").click(function(){
    $(".cenTab3").slideUp();
    $(".exp").slideDown();
})

// ====================== CV 项目经历 4 =================================
// 原生JS隐藏div
document.querySelector(".tipExpBt").onclick = function(){
    document.querySelector(".tipExp").style.display ="none";
    document.querySelector(".cenTab4").style.display ="none";
}

// jQuery显示 编辑框
$(".tipExpBt").click(function(){
    $(".cenTab4").slideDown();
})

// 完成编辑切换显示框
$(".finishBt4").click(function(){
    $(".cenTab4").slideUp();
    $(".tipExp").slideDown();
})
$(".removeBt4").click(function(){
    $(".cenTab4").slideUp();
    $(".tipExp").slideDown();
})

// ====================== CV 教育经历 5 =================================
// 原生JS隐藏div
document.querySelector(".stuBt").onclick = function(){
    document.querySelector(".stu").style.display ="none";
    document.querySelector(".cenTab5").style.display ="none";
}

// jQuery显示 编辑框
$(".stuBt").click(function(){
    $(".cenTab5").slideDown();
})

// 完成编辑切换显示框
$(".finishBt5").click(function(){
    $(".cenTab5").slideUp();
    $(".stu").slideDown();
})
$(".removeBt5").click(function(){
    $(".cenTab5").slideUp();
    $(".stu").slideDown();
})
//=====================================

//点击完成，更新个人信息，重新加载个人信息
$(".finishBt").click(function () {
    var token = localStorage.getItem("token");
    //======= personCenter用户表编辑 ==========
    var personUsername = $("#tab_username").val();
    var personJobStatus = $("#tab_status").val();
    var text1 = $("#tab_jobHunting").val();//求职状态
    var personGender = $("#tab_Gender").val();
    var personBirthday = $("#bothday").val();
    $.ajax({
        type: "post",
        url: "../../updatePersonCenter",//与myresumeController的 testIndex方法实现前后端数据交互
        headers: {"token": token},
        data: {
            personUsername: personUsername,
            personJobStatus: personJobStatus,
            text1: text1,//求职状态
            personGender: personGender,
            personBirthday:personBirthday
        },
        success: function (result) {
            console.log(result);
            //重新加载个人信息
            loadCvData();
        }
    })
})

//点击完成，更新Myresume信息，重新加载个人信息
$(".finishBt").click(function () {
    var token = localStorage.getItem("token");
    //======= Myresume表编辑 ==========
    var personalAdvantages = $("#personAdv2").val();
    var expectedPosition = $(".ejob").val();
    var expectedIndustry = $("#eindustry").val();
    // var expectationSalaryMin = $("#tab_sarlay").val();//薪资要求
    // var expectationSalaryMax = $("#tab_sarlay").val();//薪资要求
    var workArea = $("#tab_city").val();
    var myresumeTel = $("#tab_tel").val();
    var myresumeEmail = $(".tab_email").val();
    var capacity = $("#userCred2").val();//资格证书
    $.ajax({
        type: "post",
        url: "../../updateMyresume/"+myResumeId,//与myresumeController的 testIndex方法实现前后端数据交互
        headers:{"token": token},
        data:{
            personalAdvantages:personalAdvantages,
            expectedPosition:expectedPosition,
            expectedIndustry:expectedIndustry,
            // expectationSalaryMin:expectationSalaryMin,//薪资要求
            // expectationSalaryMax:expectationSalaryMax,
            workArea:workArea,
            myresumeTel:myresumeTel,
            myresumeEmail:myresumeEmail,
            test1:capacity,//资格证书
        },
        success:function (result){
            console.log(result);
            //重新加载个人信息
            loadCvData();
        }
    })
})

//点击完成，更新InternshipExperience信息，重新加载信息
$("#finishInternshipExperience").click(function () {
    var token = localStorage.getItem("token");
    //======= Myresume表编辑 ==========
    var departmentName = $(".tab_Industry").val();//部门名称
    var jobName = $("#tab_jobName").val();
    var jobCreateTime = $("#test-startDate-61").val();
    var jobEndTime = $("#test-endDate-62").val();
    var jobContent = $(".tab_jobContent").val();
    var jobSkills = $("#tab_jobSkills").val();
    $.ajax({
        type: "post",
        url: "../../updateInternship/" + idInternship,//实现前后端数据交互
        headers: {"token": token},
        data: {
            departmentName: departmentName,
            jobName: jobName,
            jobCreateTime: jobCreateTime,
            jobEndTime: jobEndTime,
            jobContent: jobContent,
            jobSkills: jobSkills//拥有技能
        },
        success: function (result) {
            console.log(result);
            //重新加载个人信息
            loadCvData();
        }
    })
})
console.log(myResumeId+"---"+idInternship+"===497");
//点击完成，更新ExperienceProject信息，重新加载个人信息
$(".finishBt").click(function () {
    var token = localStorage.getItem("token");
    //======= Myresume表编辑 ==========
    var projectName = $(".tab_projectName").val();
    var projectOperation = $(".tab_projectRole").val();
    var projectUrl = $(".tab_projectLink").val();
    var projectCreateTime = $("#test-startDate-71").val();//薪资要求
    var projectEndTime = $("#test-endDate-72").val();//薪资要求
    var projectDescription = $(".tab_projectcontent").val();
    var projectPerformance = $(".tab_projectAchievement").val();
    $.ajax({
        type: "post",
        url: "../../experCienceProject/updateProject/" + myResumeId,//实现前后端数据交互
        headers:{"token": token},
        data:{
            projectName:projectName,
            projectOperation:projectOperation,
            projectUrl:projectUrl,
            projectCreateTime:projectCreateTime,
            projectEndTime:projectEndTime,
            projectDescription:projectDescription,
            projectPerformance:projectPerformance,
        },
        success:function (result){
            console.log(result);
            //重新加载个人信息
            loadCvData();
        }
    })
})
console.log(myResumeId+"---"+idInternship+"===533");
//点击完成，更新EducationalExperience信息，重新加载个人信息
$(".finishBt").click(function () {
    var token = localStorage.getItem("token");
    //======= Myresume表编辑 ==========
    var educationalName = $(".tab_shoolName").val();
    var educationalTypeOfSchooling = $(".tab_shoolType").val();
    var educationalEducation = $(".tab_education").val();
    var educationalMajor = $("#tab_major").val();
    var educationalSchoolPeriod = $("#test-startDate-81").val();
    var educationalAssociationActivity = $(".tab_shoolExperience").val();
    $.ajax({
        type: "post",
        url: "../../edu/updateEducational/"+myResumeId,//实现前后端数据交互
        headers:{"token": token},
        data:{
            educationalName:educationalName,
            educationalTypeOfSchooling:educationalTypeOfSchooling,
            educationalEducation:educationalEducation,
            educationalMajor:educationalMajor,
            educationalSchoolPeriod:educationalSchoolPeriod,
            educationalAssociationActivity:educationalAssociationActivity,
        },
        success:function (result){
            console.log(result);
            //重新加载个人信息
            loadCvData();
        }
    })
})

//修改公司表，后期影响？？？

// })
